#唐门优测
#道长最帅666
from api import client
from common.read_yaml import get_yaml_filepath
from common.readCofig import Envison
from common.read_token import read_token
from common.logintoken import *
from until.phone import TestFaker
data = get_yaml_filepath(Envison=Envison)

class MemberControllerApi(client.HttpClient):

    def __init__(self,token):
        self.host = data['admin_host']
        xin_token = read_token(token)
        self.token = xin_token

    """-------------------------------商城前台------------------------------------"""
    "登录接口"
    def login(self,username,password):
        return login1(username,password)

    "获取注册验证码"
    data0 = get_auth_code['case_data'][0]['body']
    def get_auth_code(self,telephone = TestFaker().get_phone_number()):

        etc = {
            "telephone":telephone
        }
        url = get_auth_code['url']
        method = get_auth_code['method']
        url = self.get_full_url(url,etc=etc)
        return self.send(url,method=method)

    "注册"
    data0 = register['case_data'][0]['body']
    def register(self,
                 authCode=data0['authCode']
                ,password=data0['password']
                ,telephone=data0['telephone']
                ,username=data0['username']
                 ):
        etc = {
            "authCode":authCode
            ,"password":password
            ,"telephone":telephone
            ,"username":username
        }

        url = register['url']
        method = register['method']
        url = self.get_full_url(url,etc=etc)
        return self.send(url,method=method)


